package indi.madoka.weeb.module.base.service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import lombok.extern.slf4j.Slf4j;

import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;

@Service
@Slf4j
public class YosoroService {

    private static final String BASE_URL = "http://yosoro.site";

    private final WebClient webClient = WebClient.create(BASE_URL);

    public JSONObject createImage(String pm) {
        return JSON.parseObject(
                webClient.get()
                        .uri("/aip?pm=" + pm)
                        .retrieve()
                        .bodyToMono(String.class)
                        .block());
    }

    public String drawCard(String lx, Integer id){
        return  webClient.get()
                .uri("/gsgc?id=" + id + "&lx=" + lx)
                .retrieve()
                .bodyToMono(String.class)
                .block();
    }

    public String getWeaponRecord(Integer id) {
        return  webClient.get()
                .uri("/gsgcdw?id=" + id)
                .retrieve()
                .bodyToMono(String.class)
                .block();
    }

    public String getCharacterRecord(Integer id) {
        return  webClient.get()
                .uri("/gsgcdr?id=" + id)
                .retrieve()
                .bodyToMono(String.class)
                .block();
    }

}
